home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / redo / redoMarkLargeObjOnPage.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  5.2 KB  |  203 lines

  1. /*
  2.  *   $RCSfile: redoMarkLargeObjOnPage.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:58 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38.  
  39. #include "sysdefs.h"
  40. #include "ess.h"
  41. #include "checking.h"
  42. #include "trace.h"
  43. #include "error.h"
  44. #include "list.h"
  45. #include "tid.h"
  46. #include "io.h"
  47. #include "lock.h"
  48. #include "object.h"
  49. #include "msgdefs.h"
  50. #include "thread.h"
  51. #include "latch.h"
  52. #include "semaphore.h"
  53. #include "link.h"
  54. #include "lsn.h"
  55. #include "bf.h"
  56. #include "log.h"
  57. #include "pool.h"
  58. #include "volume.h"
  59. #include "logrecs.h"
  60. #include "trans.h"
  61. #include "bitmap.h"
  62. #include "file.h"
  63. #include "openlog.h"
  64. #include "bf_extfuncs.h"
  65. #include "trans_extfuncs.h"
  66. #include "redo_extfuncs.h"
  67. #include "logaction.h"
  68. #include "util_funcs.h"
  69. #include "thread_globals.h"
  70. #include "bf_globals.h"
  71. #include "log_globals.h"
  72. #include "log_extfuncs.h"
  73.  
  74.  
  75.  void
  76. redoMarkLargeObjOnPage (
  77.  
  78.     LOGRECORDHDR        *record 
  79. )
  80. {
  81.  
  82.     register PID        *pid;
  83.     register FOUR        *foundLoc;
  84.     register SHORTPID    *key;
  85.     register NODEPAGE    *nodePage;
  86.     register GROUPLINK    *nodeLink;
  87.     DIRTYPAGEINFO        *dirtyInfo;
  88.     SHORTPID            *gotPid;
  89.  
  90.     TRPRINT(TR_IO|TR_LOG, TR_LEVEL_1, ("lsn:%d", record->recordLSN.offset));
  91.  
  92.     /*
  93.      *    get a pointer to the affected page id
  94.      */
  95.     pid = &(record->actionPid);
  96.     TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid:%d", pid->page));
  97.  
  98.     /*
  99.      *    get a pointer to the found location in the record
  100.      */
  101.     foundLoc = (FOUR *) GET_LOG_IMAGE(record, 0);
  102.     TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("foundLoc:%d", *foundLoc));
  103.  
  104.     /*
  105.      *    get a pointer to the key inserted in the record
  106.      */
  107.     key = (SHORTPID *) GET_LOG_IMAGE(record, 1);
  108.     TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("key:%d", *key));
  109.  
  110.     /*
  111.      *    check to see if the page is in the dirty page list
  112.      */
  113.     if ((dirtyInfo = searchDirtyPageTable(pid)) == NULL)    {
  114.  
  115.         /*
  116.          *    don't need to redo
  117.          */
  118.         TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty page not present"));
  119.         return;
  120.     }
  121.  
  122.     /*
  123.      *  check to see if the lrc on the page is greater than
  124.      *  the lrc in the log record.
  125.      *  Also check the lsn for the case of pages which never made it
  126.      *  back from the client.
  127.      */
  128.     if (CHECK_PAGE_LRC_LESS_DIRTYINFO(record->actionLRC, record->recordLSN, dirtyInfo)) {
  129.  
  130.         /*
  131.          *  don't need to redo
  132.          */
  133.         TRPRINT(TR_RECOVER, TR_LEVEL_2, ("dirty info page lrc later"));
  134.         return;
  135.     }
  136.  
  137.     /*
  138.      * Read in first page of file and grab node type
  139.      */
  140.     if ((nodeLink = bf_ReadPage(UserBufGroup, pid, FILE_PAGE2SIZE, BF_SEM)) == NULL) {
  141.  
  142.         SM_ERROR(TYPE_FATAL, Active->errno);
  143.     }
  144.  
  145.     /*
  146.      *    get a pointer to the node page
  147.      */
  148.     nodePage = (NODEPAGE *) nodeLink->bufFrame;
  149.  
  150.     /*
  151.      *    check to see if the lsn on the page is greater than
  152.      *    the lrc in the log record
  153.      */
  154.     if (compareLRC( &(record->actionLRC), &(nodePage->header.lrc)) <= 0) {
  155.  
  156.         /*
  157.          *    don't need to redo
  158.          *    mark the page lrc
  159.          */
  160.         TRPRINT(TR_RECOVER, TR_LEVEL_2, ("actual page lrc later"));
  161.         dirtyInfo->lrc = nodePage->header.lrc;
  162.  
  163.         /*
  164.          *    release the page
  165.          */
  166.         signalSemaphore( &(nodeLink->pageHash->semaphore) );
  167.         bf_UnfixPage(nodeLink, BF_DEFAULT, FALSE);
  168.         return;
  169.     }
  170.  
  171.     /*
  172.      *  extract the pid from the page, making sure the page
  173.      *    is not already marked as having a large object, and that
  174.      *    the page is the correct one
  175.      */
  176.     gotPid = &(nodePage->contents.keyPid.allKeys[*foundLoc].key);
  177.     SM_ASSERT(LEVEL_3, !(*gotPid & SETLARGE));
  178.     SM_ASSERT(LEVEL_3, (*gotPid & LARGEMASK) == *key);
  179.  
  180.     /*
  181.      *    Redo the marking
  182.      */
  183.     *gotPid |= SETLARGE;
  184.  
  185.     /*
  186.      *    mark the lrc on the page
  187.      *    Set up the firstLSN/LRC for the page
  188.      */
  189.     nodePage->header.lrc = record->actionLRC;
  190.     DEPEND_LOG(nodeLink->pageHash, 0, &(record->recordLSN), &(record->actionLRC));
  191.     TRPRINT(TR_RECOVER, TR_LEVEL_2, ("marking new page lrc:%d", nodePage->header.lrc.count));
  192.  
  193.     /*
  194.      *    release  the page semaphore
  195.      */
  196.     signalSemaphore( &(nodeLink->pageHash->semaphore) );
  197.  
  198.     /*
  199.      *    release and dirty the page
  200.      */
  201.     bf_UnfixPage(nodeLink, BF_DEFAULT, TRUE);
  202. }
  203.